home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 329 / x4mersc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-18  |  5.7 KB  |  171 lines

  1.  
  2. /***************************************************************************
  3.  
  4.     X4MERSC.C
  5.  
  6.     - code for inline resource trees
  7.  
  8.     Code from:
  9.         FIXTREE  -  by Guy L. Albertelli
  10.         4142 Highland Dr.
  11.         Mogadore, Oh.  44260
  12.  
  13.     01/24/88 created
  14.  
  15.     05/18/88 22:00
  16.  
  17. ***************************************************************************/
  18.  
  19. #define LONG long
  20. #define WORD int
  21. #define BYTE char
  22.  
  23. #include <gemdefs.h>
  24. #include <obdefs.h>
  25.  
  26. #include "x4merII2.rsh"
  27.  
  28. extern WORD global[];
  29.  
  30. /****************************************************************/
  31. /* This routine does the equivalent of a rscr_load() and fixup  */
  32. /****************************************************************/
  33. fix_tree()
  34.     {
  35.     WORD num = NUM_TREE;
  36.     LONG *pl;
  37.     WORD i,j;
  38.  
  39.     pl = (LONG *)&global[5];
  40.     *pl = (LONG)rs_trindex;
  41.  
  42.     for (i=0;i<num;i++)
  43.         {
  44.         j = rs_trindex[i];  /* get index of top obj in tree */
  45.         rs_trindex[i] = (LONG)&rs_object[j];
  46.         fix_object(i,j,j);  /* fix top object then all rest */
  47.         fix_level(i,rs_object[j].ob_head,rs_object[j].ob_tail,j);
  48.         }
  49.     }
  50.  
  51. /****************************************************************/
  52. /*  This routine will clear the pointer to the resource         */
  53. /*  tree so that GEM doesn't try to free the memory             */
  54. /****************************************************************/
  55. unfix_tree()
  56.     {
  57.     LONG *pl;
  58.     pl = (LONG *) &global[5];
  59.     *pl = 0L;
  60.     }
  61.  
  62. /****************************************************************/
  63. /*  This routine will cycle across a level in the resource      */
  64. /*  tree and fix each object in that level. After fixing        */
  65. /*  up the object, it will use itself (recursion) to fix        */
  66. /*  any objects on a level below.                               */
  67. /*                                                              */
  68. /* INPUT:                                                       */
  69. /*  tr_x    index in rs_trindex of the tree being done          */
  70. /*      needed by fix_object                                    */
  71. /*  h   object number within tree of first item in              */
  72. /*      this level                                              */
  73. /*  t   object number within tree of last item in               */
  74. /*      this level                                              */
  75. /*      item in tree                                            */
  76. /****************************************************************/
  77. fix_level(tr_x,h,t,to)
  78. WORD    tr_x,h,t,to;
  79.     {
  80.     WORD i,nh,nt;
  81.  
  82.     if(h==-1 && t==-1)
  83.         return;  /* nobody on this level */
  84.     do 
  85.         {
  86.         i = to + h;
  87.         fix_object(tr_x,i,to);  /* fix this object up   */
  88.         nh = rs_object[i].ob_head;  /* get next head */
  89.         nt = rs_object[i].ob_tail;  /* and tail indexes */ 
  90.         fix_level(tr_x,nh,nt,to); /* then fix the next level down */
  91.         h = rs_object[i].ob_next; /* go to next obj on this level */
  92.         } while(t+to!=i);   /* till we have done the tail item */
  93.     }
  94.  
  95. /****************************************************************/
  96. /*  This routine will fix up the pointers in each object        */
  97. /*  and any associated control blocks. It will then use         */
  98. /*  rsrc_obfix to update the pixel information to adjust        */
  99. /*  for the current resolution and display format.              */
  100. /*                                                              */
  101. /* INPUT:                                                       */
  102. /*  tr_x    index in rs_trindex of the tree being done          */
  103. /*      needed by rsrc_obfix                                    */
  104. /*  i   object number within rs_object to fixup                 */
  105. /*  to  object number within rs_object of tree top              */
  106. /****************************************************************/
  107. fix_object(tr_x,i,to)
  108. WORD    tr_x,i,to;
  109.     {
  110.     WORD k;
  111.     LONG tst;
  112.  
  113.     tst = (LONG)rs_object[i].ob_spec; /* get current ob_spec value */
  114.     k = (WORD) tst;
  115.  
  116.     switch(rs_object[i].ob_type)
  117.         {   /* handle things depending on type */
  118.  
  119.     case G_TEXT:
  120.     case G_BOXTEXT:
  121.     case G_FTEXT:
  122.     case G_FBOXTEXT:
  123.         if (tst!=-1L)
  124.             {
  125.             rs_object[i].ob_spec = (char *) &rs_tedinfo[k];
  126.             rs_tedinfo[k].te_ptext = 
  127.                 rs_strings[(int)(rs_tedinfo[k].te_ptext)];
  128.             rs_tedinfo[k].te_ptmplt = 
  129.                 rs_strings[(int)(rs_tedinfo[k].te_ptmplt)];
  130.             rs_tedinfo[k].te_pvalid = 
  131.                 rs_strings[(int)(rs_tedinfo[k].te_pvalid)];
  132.             }
  133.         break;
  134.     case G_BUTTON:
  135.     case G_STRING:
  136.     case G_TITLE:
  137.         if (tst!=-1L) {
  138.             rs_object[i].ob_spec = 
  139.                 rs_strings[k];
  140.         }
  141.         break;
  142.     case G_ICON:
  143.         if (tst!=-1L)
  144.             {
  145.             rs_object[i].ob_spec = 
  146.                 (char *) &rs_iconblk[k];
  147.             rs_iconblk[k].ib_pmask=
  148.                 rs_imdope[(int)(rs_iconblk[k].ib_pmask)].image;
  149.             rs_iconblk[k].ib_pdata=
  150.                 rs_imdope[(int)(rs_iconblk[k].ib_pdata)].image;
  151.             rs_iconblk[k].ib_ptext =
  152.                 rs_strings[(int)(rs_iconblk[k].ib_ptext)];
  153.             }
  154.         break;
  155.     case G_IMAGE:
  156.         if (tst!=-1L)
  157.             { 
  158.             rs_object[i].ob_spec = 
  159.                 (char *) &rs_bitblk[k];
  160.             rs_bitblk[k].bi_pdata=
  161.                 rs_imdope[(int)(rs_bitblk[k].bi_pdata)].image;
  162.             }
  163.         break;
  164.     case G_BOX:
  165.     case G_IBOX:
  166.     case G_BOXCHAR:
  167.         break;
  168.         }
  169.     rsrc_obfix(rs_trindex[tr_x],i-to);  /* fix pixel values for rez */
  170.     }
  171.